home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / whomp.swf / scripts / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2007-04-20  |  3.1 KB  |  117 lines

  1. _global.home = this;
  2. gk1 = "whomp";
  3. loadVariables(userInfoURL,this);
  4. gotKey = true;
  5. _global.loadScores = function(score, obj)
  6. {
  7.    trace("load obj: " + obj);
  8.    delete home.scoreList;
  9.    home.scoreList = new LoadVars();
  10.    trace("Initiating Load");
  11.    home.scoreList.onLoad = function(success)
  12.    {
  13.       if(success)
  14.       {
  15.          trace("Highscores loaded successfully.");
  16.          for(var _loc1_ in home.scoreList)
  17.          {
  18.             trace(_loc1_ + " -> " + home.scoreList[_loc1_]);
  19.          }
  20.          setScores(1,obj);
  21.       }
  22.       else
  23.       {
  24.          setScores(0,obj);
  25.          trace("An error occurred while loading highscores.");
  26.       }
  27.    };
  28.    if(score != undefined)
  29.    {
  30.       trace("You have submitted a score to the list");
  31.       home.scoreList.load(score);
  32.    }
  33.    else
  34.    {
  35.       var _loc2_ = home.highScoresURL + "?gk=" + home.gk1;
  36.       trace("You have requested the highscore list");
  37.       home.scoreList.load(_loc2_);
  38.    }
  39. };
  40. _global.getScores = function(score, obj)
  41. {
  42.    trace("get obj: " + obj);
  43.    if(score != undefined || score != null)
  44.    {
  45.       var _loc1_ = score;
  46.       var _loc4_ = home.highScoresURL + "?gk=" + home.gk1 + "&uk=" + home.userKey + "&s=" + _loc1_ + "&es=" + encrypt(_loc1_) + "&sd=" + home.seed;
  47.       loadScores(_loc4_,obj);
  48.    }
  49.    else
  50.    {
  51.       loadScores(null,obj);
  52.    }
  53. };
  54. _global.setScores = function(type, obj)
  55. {
  56.    trace("set obj: " + obj);
  57.    if(type)
  58.    {
  59.       if(home.scoreList.rank != undefined)
  60.       {
  61.          home.returnedInfo = "Good Job, you\'ve made the list. Your RANK is " + home.scoreList.rank;
  62.       }
  63.       else
  64.       {
  65.          home.returnedInfo = "You\'re score did not make the list";
  66.       }
  67.       var _loc1_ = 1;
  68.       while(_loc1_ <= 10)
  69.       {
  70.          obj["total_" + _loc1_] = home.scoreList["hs_" + _loc1_ + "_score"] + " pts - " + home.scoreList["hs_" + _loc1_ + "_username"];
  71.          _loc1_ = _loc1_ + 1;
  72.       }
  73.    }
  74. };
  75. _global.encrypt = function(encScore)
  76. {
  77.    encScore = encScore.toString();
  78.    my_date = new Date();
  79.    my_date.hours = my_date.getUTCHours();
  80.    my_date.minutes = my_date.getUTCMinutes();
  81.    my_date.seconds = my_date.getUTCSeconds();
  82.    if(my_date.seconds < 10)
  83.    {
  84.       my_date.seconds = "0" + my_date.seconds;
  85.    }
  86.    if(my_date.minutes < 10)
  87.    {
  88.       my_date.minutes = "0" + my_date.minutes;
  89.    }
  90.    if(my_date.hours < 10)
  91.    {
  92.       my_date.hours = "0" + my_date.hours;
  93.    }
  94.    home.seed = my_date.hours + ":" + my_date.minutes + ":" + my_date.seconds + ":28";
  95.    charList = new Array(2,8,10,5,4,1,11,7);
  96.    keyChars = new Array();
  97.    i = 0;
  98.    while(i < 8)
  99.    {
  100.       var _loc1_ = charList[i];
  101.       keyChars.push(seed.charAt(_loc1_ - 1));
  102.       i++;
  103.    }
  104.    snafuText = "";
  105.    i = 0;
  106.    while(i < encScore.length)
  107.    {
  108.       tempHolder = keyChars.shift();
  109.       keyChars.push(tempHolder);
  110.       tempName = "ascii" + i;
  111.       tempName = encScore.charCodeAt(i) + Math.round(tempHolder);
  112.       snafuText = snafuText add String.fromCharCode(tempName);
  113.       i++;
  114.    }
  115.    return snafuText;
  116. };
  117.